Skip to content

feat: Preview PDF attachments in the modal#81

Closed
akrost wants to merge 1 commit intoRasalas:mainfrom
akrost:feat/pdf-in-modal-preview
Closed

feat: Preview PDF attachments in the modal#81
akrost wants to merge 1 commit intoRasalas:mainfrom
akrost:feat/pdf-in-modal-preview

Conversation

@akrost
Copy link
Copy Markdown

@akrost akrost commented Apr 10, 2026

Summary

Clicking a PDF attachment now opens the in-app preview modal (same as images and text), instead of triggering an immediate browser download or opening an external viewer on desktop.

Changes

  • Preview routing: *.pdf files with empty, application/octet-stream, or binary/octet-stream MIME are treated as PDFs so the attachment row uses "preview" instead of "download only" (which previously led to Save As on Tauri or a forced download in the browser).
  • Rendering: PDFs are shown in the modal via an <object> pointed at a blob: URL built from decoded attachment bytes; the blob URL is revoked when switching attachments or closing the modal.
  • Desktop: Removed the Tauri-only path that opened PDFs with the system default app and dropped the open_file_with_system Rust command and openWithSystemViewer bridge helper. Explicit download still uses Save As (save_file_with_dialog) or the browser download control.
  • Tests: Jest mocks URL.createObjectURL / revokeObjectURL; unit tests cover MIME/filename PDF detection and Tauri opening the modal for PDFs.
  • Docs: AGENTS.md updated to match the above.

Verification

  • cargo check (src-tauri): success
  • npm run lint, npm test, npm run build: success

Note: npm run format fails in this repo due to an invalid Prettier arrowParens value in config (pre-existing).

Made with Cursor

- Treat .pdf files with generic binary MIME as previewable (fixes download/Save As on row click)
- Render PDF preview via Blob URL in object; revoke on navigation and close
- Remove Tauri system-viewer PDF bypass and open_file_with_system command
- Mock URL.createObjectURL in Jest setup; update tests and AGENTS.md

Made-with: Cursor
@Rasalas
Copy link
Copy Markdown
Owner

Rasalas commented May 1, 2026

Hi,

thanks for your contribution, but I chose to go a slightly different path.

I didn't like how you just decided to remove the currently working "open via system"-part. That was a deliberate decision in the beginning (modal-view was broken on some systems).

I now added a user setting so users can choose what they prefer (and fixed visual bugs).

@Rasalas Rasalas closed this May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants